﻿////using System;
////using System.Collections.Generic;
////using System.Linq;
////using System.Text;

////namespace MetaProperties.Core
////{
////    using System.ComponentModel;
////    using System.Linq.Expressions;

////    using Framework;

////    [Obsolete]
////    public class PropertyChangedAdapter<TSource, TValue> : GenericBoundObservable<TValue>
////        where TSource : class, INotifyPropertyChanged
////    {
////        private string propertyName;

////        private TSource source;

////        private Func<TSource, TValue> getValueMethod;

////        public PropertyChangedAdapter()
////        {
////        }

////        public PropertyChangedAdapter(TValue defaultValue)
////        {
////            this.DefaultValue = defaultValue;
////        }

////        public PropertyChangedAdapter(TSource source, string propertyName, Func<TSource, TValue> getValueMethod)
////            : this(default(TValue), source, propertyName, getValueMethod)
////        {
////        }

////        public PropertyChangedAdapter(TValue defaultValue, TSource source, string propertyName, Func<TSource, TValue> getValueMethod)
////            : this(defaultValue)
////        {
////            this.SetSource(source, propertyName, getValueMethod);
////        }

////        public PropertyChangedAdapter(TSource source, Expression<Func<TSource, TValue>> propertyExpression)
////            : this(default(TValue), source, propertyExpression)
////        {
////        }

////        public PropertyChangedAdapter(TValue defaultValue, TSource source, Expression<Func<TSource, TValue>> propertyExpression)
////            : this(defaultValue)
////        {
////            this.SetSource(source, propertyExpression);
////        }

////        public void SetSource(TSource source, Expression<Func<TSource, TValue>> propertyExpression)
////        {
////            string name = PropertyNameHelper.GetProperty(propertyExpression).Name;
////            Func<TSource, TValue> method = propertyExpression.Compile();
////            this.SetSource(source, name, method);
////        }

////        public void SetSource(TSource source, string propertyName, Func<TSource, TValue> getValueMethod)
////        {
////            if (source == null)
////            {
////                throw new ArgumentNullException("source");
////            }

////            this.ClearSource();

////            this.source = source;
////            this.propertyName = propertyName;
////            this.getValueMethod = getValueMethod;

////            this.ObservableValue.Value = this.getValueMethod(this.source);

////            this.source.PropertyChanged += this.Source_PropertyChanged;
////        }

////        public override void Unbind()
////        {
////            this.ClearSource();
////        }

////        protected override bool IsBound
////        {
////            get { return this.IsSourceSet; }
////        }

////        public void ClearSource()
////        {
////            if (this.source != null)
////            {
////                this.source.PropertyChanged -= this.Source_PropertyChanged;

////                this.source = null;
////                this.propertyName = null;
////                this.getValueMethod = null;

////                this.ObservableValue.Value = this.DefaultValue;
////            }
////        }

////        void Source_PropertyChanged(object sender, PropertyChangedEventArgs e)
////        {
////            if (e.PropertyName == this.propertyName)
////            {
////                this.ObservableValue.Value = this.getValueMethod(this.source);
////            }
////        }

////        protected bool IsSourceSet
////        {
////            get { return this.source != null; }
////        }
////    }
////}
